home *** CD-ROM | disk | FTP | other *** search
- Using a sorted sequence to list all elements in a sequence of strings lying
- lexicographically between two given search strings.
-
- \#include $<$LEDA/sortseq.h$>$
- \medskip
- \cleartabs
- \+main()\cr
- \+$\{$\ \
- &sortseq\<string,int\> $S$;\cr
- \+ &string $s_1,s_2$;\cr
- \smallskip
- \+ &\While ( cin $>>$ $s_1$ \&\& $s_1$ != ``stop'' ) $S$.insert($s_1,0$);\cr
- \smallskip
- \+ &\While ( cin $>>$ $s_1$ $>>$ $s_2$ )\cr
- \+ &\ \ \ &$\{$\ \ &seq\_item $stop = S$.locate($s_2$);\cr
- \smallskip
- \+ & & &\For (seq\_item $it = S$.locate($s_1$); $it$ != $stop$; $it = S$.succ($it$))\cr
- \+ & & &\ \ \ \ cout $<<$ $S$.key($it$) $<<$ ``\n"; \cr
- \+ & &\ $\}$\cr
- \+\ $\}$\cr
-